#
# Be sure to run `pod lib lint MirrorRealm.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'MirrorRealm'
  s.version          = '0.3.0'
  s.summary          = 'MirrorRealm can export the Realm to swift as a framework module.'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
TODO: MirrorRealm can export the Realm to swift as a framework module.
                       DESC

  s.homepage         = 'https://gitee.com/tjerwinchen/mirror-realm'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'Theo Chen' => 'me@theochen.com' }
  s.source           = { :git => 'https://gitee.com/tjerwinchen/mirror-realm.git', :tag => 'Realm-' + s.version.to_s }
  s.social_media_url = 'https://twitter.com/realm'

  s.library = 'c++', 'z'

  s.cocoapods_version = '>= 1.10.0'
  s.static_framework = false
  s.prefix_header_file = false
  
  public_header_files       = 'Mirror/Realm/include/**/MirrorRealm.h',
  # Realm module
                                'Mirror/Realm/include/**/RLMArray.h',
                                'Mirror/Realm/include/**/RLMCollection.h',
                                'Mirror/Realm/include/**/RLMConstants.h',
                                'Mirror/Realm/include/**/RLMDecimal128.h',
                                'Mirror/Realm/include/**/RLMEmbeddedObject.h',
                                'Mirror/Realm/include/**/RLMListBase.h',
                                'Mirror/Realm/include/**/RLMMigration.h',
                                'Mirror/Realm/include/**/RLMObject.h',
                                'Mirror/Realm/include/**/RLMObjectBase.h',
                                'Mirror/Realm/include/**/RLMObjectId.h',
                                'Mirror/Realm/include/**/RLMObjectSchema.h',
                                'Mirror/Realm/include/**/RLMOptionalBase.h',
                                'Mirror/Realm/include/**/RLMPlatform.h',
                                'Mirror/Realm/include/**/RLMProperty.h',
                                'Mirror/Realm/include/**/RLMRealm.h',
                                'Mirror/Realm/include/**/RLMRealmConfiguration.h',
                                'Mirror/Realm/include/**/RLMResults.h',
                                'Mirror/Realm/include/**/RLMSchema.h',
                                'Mirror/Realm/include/**/RLMThreadSafeReference.h',
                                
                                # Sync
                                'Mirror/Realm/include/**/NSError+RLMSync.h',
                                'Mirror/Realm/include/**/RLMApp.h',
                                'Mirror/Realm/include/**/RLMAppCredentials.h',
                                'Mirror/Realm/include/**/RLMBSON.h',
                                'Mirror/Realm/include/**/RLMNetworkTransport.h',
                                'Mirror/Realm/include/**/RLMPushClient.h',
                                'Mirror/Realm/include/**/RLMProviderClient.h',
                                'Mirror/Realm/include/**/RLMRealm+Sync.h',
                                'Mirror/Realm/include/**/RLMRealmConfiguration+Sync.h',
                                'Mirror/Realm/include/**/RLMSyncConfiguration.h',
                                'Mirror/Realm/include/**/RLMCredentials.h',
                                'Mirror/Realm/include/**/RLMSyncManager.h',
                                'Mirror/Realm/include/**/RLMSyncSession.h',
                                'Mirror/Realm/include/**/RLMUser.h',
                                'Mirror/Realm/include/**/RLMSyncUtil.h',
                                'Mirror/Realm/include/**/RLMUserAPIKey.h',
                                'Mirror/Realm/include/**/RLMAPIKeyAuth.h',
                                'Mirror/Realm/include/**/RLMEmailPasswordAuth.h',
                                'Mirror/Realm/include/**/RLMFindOneAndModifyOptions.h',
                                'Mirror/Realm/include/**/RLMFindOptions.h',
                                'Mirror/Realm/include/**/RLMMongoClient.h',
                                'Mirror/Realm/include/**/RLMMongoCollection.h',
                                'Mirror/Realm/include/**/RLMMongoDatabase.h',
                                'Mirror/Realm/include/**/RLMUpdateResult.h',
                              

                              # Realm.Dynamic module
                              'Mirror/Realm/include/**/RLMRealm_Dynamic.h',
                              'Mirror/Realm/include/**/RLMObjectBase_Dynamic.h'

                              # Realm.Private module
  private_header_files      = 'Mirror/Realm/include/**/RLMAccessor.h',
                              'Mirror/Realm/include/**/RLMArray_Private.h',
                              'Mirror/Realm/include/**/RLMApp_Private.h',
                              'Mirror/Realm/include/**/RLMBSON_Private.h',
                              'Mirror/Realm/include/**/RLMCollection_Private.h',
                              'Mirror/Realm/include/**/RLMListBase.h',
                              'Mirror/Realm/include/**/RLMObjectBase_Private.h',
                              'Mirror/Realm/include/**/RLMObjectSchema_Private.h',
                              'Mirror/Realm/include/**/RLMObjectStore.h',
                              'Mirror/Realm/include/**/RLMObject_Private.h',
                              'Mirror/Realm/include/**/RLMOptionalBase.h',
                              'Mirror/Realm/include/**/RLMProperty_Private.h',
                              'Mirror/Realm/include/**/RLMRealmConfiguration_Private.h',
                              'Mirror/Realm/include/**/RLMRealm_Private.h',
                              'Mirror/Realm/include/**/RLMResults_Private.h',
                              'Mirror/Realm/include/**/RLMSchema_Private.h',
                              'Mirror/Realm/include/**/RLMSyncConfiguration_Private.h',
                              'Mirror/Realm/include/**/RLMSyncUtil_Private.h',
                              'Mirror/Realm/include/**/RLMFindOneAndModifyOptions_Private.h',
                              'Mirror/Realm/include/**/RLMFindOptions_Private.h',
                              'Mirror/Realm/include/**/RLMMongoClient_Private.h',
                              'Mirror/Realm/include/**/RLMMongoCollection_Private.h',
                              'Mirror/Realm/include/**/RLMMongoDatabase_Private.h',
                              'Mirror/Realm/include/**/RLMUpdateResult_Private.h',
                              'Mirror/Realm/include/**/RLMUser_Private.h',
                              'Mirror/Realm/include/**/RLMProviderClient_Private.h'
                 
  s.frameworks = 'Security'
  s.module_map = "Mirror/Realm/Realm/MirrorRealm.modulemap"
  s.compiler_flags = "-DREALM_HAVE_CONFIG -DREALM_COCOA_VERSION='@\"#{s.version.to_s}\"' -D__ASSERTMACROS__ -DREALM_ENABLE_SYNC"

  s.source_files = private_header_files + ['Mirror/Realm/Realm/*.{m,mm}']
  s.private_header_files = private_header_files
  s.header_mappings_dir = "Mirror/Realm/include"

  s.pod_target_xcconfig = {
    "APPLICATION_EXTENSION_API_ONLY" => "YES",
    "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
    "CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF" => "NO",
    'OTHER_CPLUSPLUSFLAGS' => '-isystem "${PODS_ROOT}/MirrorRealm/Mirror/Realm/include/core" -fvisibility-inlines-hidden',
    'OTHER_CPLUSPLUSFLAGS[arch=armv7]' => '-isystem "${PODS_ROOT}/MirrorRealm/Mirror/Realm/include/core" -fvisibility-inlines-hidden -fno-aligned-new',
    'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/MirrorRealm/Mirror/Realm/include" "${PODS_ROOT}/MirrorRealm/Mirror/Realm/include/Realm"',
    
#    "OTHER_CPLUSPLUSFLAGS" => "-isystem \"${PODS_ROOT}/../../Mirror/Realm/include/core\" -fvisibility-inlines-hidden",
#    'OTHER_CPLUSPLUSFLAGS[arch=armv7]' => '-isystem "${PODS_ROOT}/../../Mirror/Realm/include/core" -fvisibility-inlines-hidden -fno-aligned-new',
#    "USER_HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/../../Mirror/Realm/include\" \"${PODS_ROOT}/../../Mirror/Realm/include/Realm\""
  }

  s.ios.deployment_target   = '9.0'
  s.osx.deployment_target   = '10.9'
  s.watchos.deployment_target = '2.0'
  s.tvos.deployment_target = '9.0'
  
  s.preserve_paths = [
    "Mirror/Realm/README.md",
    "Mirror/Realm/CHANGELOG.md",
    "Mirror/Realm/build.sh",
    "Mirror/Realm/include"
  ]
  
  s.vendored_frameworks  = 'Mirror/Realm/core/realm-monorepo.xcframework'

  s.subspec 'Headers' do |s|
    s.source_files          = public_header_files
    s.public_header_files   = public_header_files
  end

end
